This post will be showing how I created a choropleth map that shows which states had more deaths due to COVID as of Feb. 22 compared with others.
The first thing I did was download the necessary packages and then import the New York Time’s COVID case data for US states. I also downloaded the polygon boundaries for states at the lowest resolution using the tigris package.
I then filtered the covidcases data to only show the number of deaths on 2021-02-22. I selected the date, state, and deaths columns to be the only information shown. I renamed this data ‘filtered_states’. I then utilized the geo-join function in order to merge the ‘states’ and ‘filtered_states’ data sets together. After that, I ran the mypalette function and selected my map color scheme to be yellow and green. I then started adding in all of my data into the Leaflet function. I selected the appropriate coordinates and zoom level in setView and added the appropriate data in the addPolygons function. I selected the fill color, fill opacity, weight, smoothfactor, and label options. The addLegend function allowed me to add in a small box on the bottom right corner called “Total death”. I set the number of bins to 4 so that only four values were displayed. After that I ran the function and got my choropleth map.
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|=== | 6%
|
|==== | 6%
|
|===== | 8%
|
|===== | 9%
|
|====== | 9%
|
|====== | 10%
|
|====== | 11%
|
|======= | 11%
|
|======= | 12%
|
|======== | 13%
|
|========= | 15%
|
|============ | 20%
|
|============= | 22%
|
|============== | 23%
|
|============== | 24%
|
|=============== | 24%
|
|=============== | 25%
|
|================ | 26%
|
|================ | 27%
|
|================== | 29%
|
|================== | 30%
|
|================== | 31%
|
|=================== | 32%
|
|==================== | 33%
|
|===================== | 36%
|
|====================== | 36%
|
|====================== | 37%
|
|======================= | 38%
|
|======================= | 39%
|
|======================== | 40%
|
|========================= | 41%
|
|========================= | 42%
|
|========================== | 43%
|
|========================== | 44%
|
|=========================== | 44%
|
|============================ | 46%
|
|============================= | 48%
|
|============================= | 49%
|
|============================== | 49%
|
|============================== | 50%
|
|=============================== | 52%
|
|================================ | 53%
|
|================================= | 54%
|
|================================= | 55%
|
|================================== | 56%
|
|================================== | 57%
|
|=================================== | 58%
|
|==================================== | 60%
|
|===================================== | 61%
|
|===================================== | 62%
|
|====================================== | 63%
|
|====================================== | 64%
|
|======================================= | 64%
|
|======================================= | 65%
|
|======================================= | 66%
|
|======================================== | 67%
|
|========================================== | 70%
|
|=========================================== | 71%
|
|=========================================== | 72%
|
|============================================ | 73%
|
|============================================ | 74%
|
|============================================= | 75%
|
|============================================== | 77%
|
|=============================================== | 78%
|
|=============================================== | 79%
|
|================================================ | 80%
|
|================================================= | 81%
|
|================================================= | 82%
|
|================================================== | 83%
|
|================================================== | 84%
|
|=================================================== | 85%
|
|==================================================== | 87%
|
|===================================================== | 89%
|
|====================================================== | 89%
|
|====================================================== | 90%
|
|======================================================= | 91%
|
|======================================================= | 92%
|
|======================================================== | 93%
|
|======================================================== | 94%
|
|========================================================= | 95%
|
|========================================================= | 96%
|
|========================================================== | 97%
|
|=========================================================== | 98%
|
|=========================================================== | 99%
|
|============================================================| 100%
```{.r .distill-force-highlighting-css}